#pragma once
#include "stdafx.h"
#include "xercescHelpingLibrary.h"

namespace xercescHelpingLibrary
{
	using namespace std;
	using namespace xercesc;

	class CXMLElement
	{
		static const string EmptyString;
		DOMElement* m_element;
		vector<CXMLElement*>* m_children;
	private:
		CXMLElement();
	public:
		~CXMLElement();
	public:
		string	getName();
		bool	hasValue();
		string	getStringValue();
		double	getDoubleValue();
		int		getIntValue();
	public:
		vector<CXMLElement*>*	getChildElements();
		CXMLElement*			getElementByAttribute(string attributeName, string attributeValue);
		tuple<string, string>	getAttributes();
		string					getAttributeValue( string attributeName ) ;
	private:
		DOMText*				getTextContent();
		static double			StringToDouble(string s);
		static int				StringToInt(string s);
		static string			XMLChToString(const XMLCh* arr);
	public:
		static CXMLElement*		CreateElement(DOMElement* element);
	private:
		static bool				CheckAttribute(DOMElement* element, XMLCh* xAttributeName, XMLCh* xAttributeValue);
		static CXMLElement*		getElementByAttribute(DOMElement* element, XMLCh* xAttributeName, XMLCh* xAttributeValue);

		//static DOMElement* CreateElement(DOMDocument* doc, string name)
		//{
		//	XMLCh* xname = new XMLCh[name.length() + 1];
		//	XMLString::transcode(name.c_str(), xname, name.length());
		//	DOMElement* r = doc->createElement(xname);
		//	delete xname;
		//	return r;
		//}
	};
}